package com.shenhaofeng.app.menu;

import android.support.v7.view.menu.MenuBuilder;
import android.view.Menu;

import java.lang.reflect.Method;


/**
 * 处理一些menu的方法集合
 * Created by Administrator on 2016/5/5.
 */
public class ActionMenuHelper {


    /**
     * 设置Menu的Icon的显示能力
     *
     * @param menu
     * @param enable
     */
    public static void setMenuIconEnable(Menu menu, boolean enable) {
        if (menu instanceof MenuBuilder) {
            MenuBuilder menuBuilder = (MenuBuilder) menu;
            try {
                Method method = menuBuilder.getClass().getDeclaredMethod("setOptionalIconsVisible", boolean.class);
                method.setAccessible(true);
                method.invoke(menuBuilder, enable);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }


}
